﻿using Cx.NetCoreUtils.Exceptions;
using Microsoft.AspNetCore.Mvc;
using Xiao.Code.Entities.Users;
using Xiao.Util;

namespace Xiao.Web.Code
{
    public class XiaoController: ControllerBase
    {
        public new ConsumerDto User { get
            {
                var token = HttpContext.Request.Headers["Authorization"].ToString();
                var user = new RedisUtil().GetAsync<ConsumerDto>(token).Result;
                if (user == null) throw new BusinessLogicException(401, "请先登录");
                return user;
            } }
    }
}
